package com.jh.paymentchannel.payment;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.jh.paymentchannel.pojo.PaymentOrder;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author Yichuan
 * @version 1.0
 */
public class OrderVo implements Serializable {

    private static final long serialVersionUID = 2784165488837080298L;

    public static OrderVo order(PaymentOrder order) {
        return new OrderVo(order.getBody(), order.getCreateTime(), order.getTradeStatus(),
                order.getTradeStatus().getDesc(), order.getTotalFee(), order.getOutTradeNo());
    }

    public static List<OrderVo> transform(List<PaymentOrder> orderList) {
        if (orderList == null || orderList.isEmpty()) {
            return ImmutableList.of();
        }
        List<OrderVo> content = Lists.newLinkedList();
        for (PaymentOrder order: orderList) {
            content.add(OrderVo.order(order));
        }
        return content;
    }

    private String desc;
    private Date createTime;
    private TradeStatus tradeStatus;
    private String statusName;
    private BigDecimal totalFee;
    private String outTradeNo;

    public OrderVo() {
        super();
    }

    public OrderVo(String desc, Date createTime, TradeStatus tradeStatus, String statusName, BigDecimal totalFee, String outTradeNo) {
        this.desc = desc;
        this.createTime = createTime;
        this.tradeStatus = tradeStatus;
        this.statusName = statusName;
        this.totalFee = totalFee;
        this.outTradeNo = outTradeNo;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public TradeStatus getTradeStatus() {
        return tradeStatus;
    }

    public void setTradeStatus(TradeStatus tradeStatus) {
        this.tradeStatus = tradeStatus;
    }

    public String getStatusName() {
        return statusName;
    }

    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }

    public BigDecimal getTotalFee() {
        return totalFee;
    }

    public void setTotalFee(BigDecimal totalFee) {
        this.totalFee = totalFee;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }
}
